home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
3_16.lha
/
3_16
/
3_16.cmp
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
112 lines
include <stream.h>
xtern void error(char *);
include "3_16b.c"
include "3_16c.c"
include "3_16d.c"
include "3_16a.c"
include <stream.h>
nt main(int, char**)
char ch;
while (cin.get(ch))
{
if (ch == '/')
{
cin.get(ch);
if (!cin)
break;
if (ch == '/') dolinecomment();
else if (ch == '*') doblockcomment();
else
{
cout.put('/');
cin.putback(ch);
}
}
else
{
cout.put(ch);
if (ch == '"' || ch == '\'')
do_string_or_char(ch);
}
}
return 0;
oid dolinecomment()
char ch;
while (cin.get(ch))
if (ch == '\n')
{
cout.put(ch);
return;
}
error("EOF found within line comment");
oid doblockcomment()
cout.put(' ');
char ch;
while (cin.get(ch))
if (ch == '*')
{
cin.get(ch);
if (ch == '/')
return;
cin.putback(ch);
}
else if (ch == '\n')
cout.put(ch);
error("EOF found within full comment");
oid do_string_or_char(char startquote)
char ch;
while (cin.get(ch))
{
cout.put(ch);
if (ch == startquote)
return;
if (ch == '\\')
{
cin.get(ch);
if (!cin)
break;
cout.put(ch);
}
}
error("EOF found within string or char constant");